package st.business.tepth.business.user.busnumber.workholder.maintain.work.content.standardwork.entity;

import com.chad.library.adapter.base.entity.AbstractExpandableItem;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.util.List;

import st.business.tepth.business.bean.MaintainWorkBean;
import st.business.tepth.business.user.busnumber.workholder.maintain.work.content.standardwork.StandardWorkAdapter;

/**
 * @author zhangyu
 * @date 2019/7/19
 */
public class Lv0 extends AbstractExpandableItem<Lv1> implements MultiItemEntity {
    private final String mName;
    private final List<MaintainWorkBean> mMaintainWorkBeans;
    private boolean isChecked;
    private int mCheckCount;
    private boolean isAllItemDone;

    public Lv0(String name, List<MaintainWorkBean> maintainWorkBeans, boolean isChecked) {
        mName = name;
        mMaintainWorkBeans = maintainWorkBeans;
        this.isChecked = isChecked;
    }

    public int getCheckCount() {
        return mCheckCount;
    }

    public boolean isAllItemDone() {
        return isAllItemDone;
    }

    public void setAllItemDone(boolean allItemDone) {
        isAllItemDone = allItemDone;
    }

    public void setCheckCount(int checkCount) {
        mCheckCount = checkCount;
        if (mCheckCount == mMaintainWorkBeans.size()) {
            setChecked(true);
        } else {
            setChecked(false);
        }
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public String getName() {
        return mName;
    }

    public List<MaintainWorkBean> getMaintainWorkBeans() {
        return mMaintainWorkBeans;
    }

    public boolean isChecked() {
        return isChecked;
    }

    @Override
    public int getLevel() {
        return 0;
    }

    @Override
    public int getItemType() {
        return StandardWorkAdapter.TYPE_0;
    }

    public boolean isAllCheck() {
        if (mMaintainWorkBeans == null || mMaintainWorkBeans.isEmpty()) {
            return false;
        }
        return mCheckCount == mMaintainWorkBeans.size();
    }
}
